Computer systems frequently have many processes running simultaneously and frequently one or more of those processes include more than one processing threads. In many cases, it is important for one or more of the processes (or threads) to share access to a resource, sometime called a “global resource,” such as a disk drive or a memory element.
Access to global resources is typically controlled, or synchronized, to prevent unpredictable results such as might result, for example, when one process writes to a global resource at the same time that another process reads from the global resource. Computer systems frequently use “locks” to exercise the required control. A “mutex” is an example of such a lock.
Different operating systems use different techniques to synchronize access to global resources. In WINDOWS, for example, for a process to establish a known mutex object the process must create the mutex object as a uniquely named entity. In contrast, if a mutex is declared under Unix in global memory, and it is initialized with shared attributes, the mutex may be accessible to all processes through pointers to the mutex in the global area.
It is desirable for the same application to run under different operating systems without requiring major modifications. Frequently, applications use the facilities provided by the operating systems to synchronize access to global resources. The different global resource synchronization techniques used by different operating systems, such as those described above, make writing applications with locking primitives that may be run on multiple operating systems a challenge.